<script setup>
import messageApi from '@/apis/message'
import {onMounted, ref} from 'vue'

// 定义通知列表
const announceList = ref([])

// 组件加载完成调用
onMounted(()=>{
	getAnnounceList()
})

// 获取通知请求
const getAnnounceList = async(page=1,pageSize=5)=>{
	const {code,data} = await messageApi.list(200,page,pageSize)
	if(code!==200) return uni.utils.toast('获取公告数据失败！')
	announceList.value = data.items
}

</script>
<template>
  <scroll-view class="scroll-view" refresher-enabled scroll-y>
    <view class="scroll-view-wrapper">
      <view class="message-action">
        <text class="iconfont icon-clear"></text>
        全部已读
      </view>
      <uni-list :border="false">
        <uni-list-item
		  v-for="announce in announceList"
		  :key="announce.id"
          to="/subpkg_message/content/index"
          ellipsis="1"
          :title="announce.title"
          :rightText="announce.created"
        >
          <template v-slot:header>
            <text v-if="!announce.isRead" class="dot"></text>
          </template>
        </uni-list-item>
      </uni-list
    ></view>
  </scroll-view>
</template>

<style lang="scss" scoped>
  @import './styles.scss';
</style>
